Passed
Push — master ( 616dea...d489a6 )
by Kolja
02:44
created

jgfNode.js ➔ constructor   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
const { Guard } = require('./guard');
2
3
/**
4
 * A node object represents a node in a graph. In graph theory, nodes are also called points or vertices.
5
 */
6
class JgfNode {
7
8
    /**
9
     * Constructor
10
     * @param {string} id Primary key for the node, that is unique for the object type.
11
     * @param {string} label A text display for the node.
12
     * @param {object|null} metadata Metadata about the node.
13
     */
14
    constructor(id, label, metadata = null) {
15
        this.id = id;
16
        this.label = label;
17
        this.metadata = metadata;
18
    }
19
20
    set metadata(metadata) {
21
        Guard.assertValidMetadataOrNull(metadata);
22
        this._metadata = metadata;
23
    }
24
25
    get metadata() {
26
        return this._metadata;
27
    }
28
}
29
30
module.exports = {
31
    JgfNode,
32
};